package cn.wolfcode.crm.web.controller;

import cn.wolfcode.crm.domain.Salary;
import cn.wolfcode.crm.query.SalaryQueryForObject;
import cn.wolfcode.crm.service.ISalaryService;
import cn.wolfcode.crm.util.JsonResult;
import cn.wolfcode.crm.util.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("salary")
public class SalaryController {
    @Autowired
    private ISalaryService service;

    @RequestMapping("index")
    public  String  index(){
        return "salary/list";
    }

    @RequestMapping("wages")
    public  String  wages(){
        return "salary/list";
    }

    @RequestMapping("list")
    @ResponseBody
    public PageResult list(SalaryQueryForObject qo){
        return service.query(qo);
    }

    @RequestMapping("save")
    @ResponseBody
    public JsonResult save(Salary salary){
        JsonResult result = null;
        try {
            if(salary.getIdentifier().getId() == null)
            {
                return new JsonResult("请输入正确的数据");
            }
            service.insert(salary);
        } catch (Exception e) {
            e.printStackTrace();
            return new JsonResult("未知错误");
        }
        return new JsonResult();
    }
    /*查找salary*/
    @RequestMapping("queryEmpSalaryByEmpId")
    @ResponseBody
    public Salary queryEmpSalaryByEmpId(Long empId){


        return service.queryEmpSalaryByEmpId(empId);
    }



}
